// import { debounce } from 'lodash-es'
export default {
  data() {
    return {
      $_resizeHandler: null,
    }
  },
  mounted() {
    const self = this
    this.$_resizehandler = () => {
      if (self.chart) {
        setTimeout(() => {
          self.chart.resize()
        }, 500)
      }
    }
    // this.$_resizehandler = function(() => {
    //   if (self.chart) {
    //     setTimeout(() => {
    //       self.chart.resize()
    //     }, 500)
    //   }
    // })
    this.$_initResizeEvent()
  },
  beforeDestroy() {
    this.$_destoryResizeEvent()
  },
  activated() {
    this.$_initResizeEvent()
  },
  deactivated() {
    this.$_destoryResizeEvent()
  },
  methods: {
    $_initResizeEvent() {
      window.addEventListener('resize', this.$_resizehandler)
    },
    $_destoryResizeEvent() {
      window.removeEventListener('resize', this.$_resizehandler)
    },
  },
}
